﻿using System.Windows.Controls;
using MMK.Paket_Tracker.GUI.ViewModels;
using MMK.Paket_Tracker.Runtime.Interfaces;
using System.Collections.Generic;
using System;
using System.Windows;

namespace MMK.Paket_Tracker.GUI.Views
{
    /// <summary>
    /// Interaction logic for NewPacketAddress.xaml
    /// </summary>
    public partial class NewPacketAddressReceiver : UserControl, INamedUserControl
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="NewPacketAddressReceiver"/> class.
        /// </summary>
        public NewPacketAddressReceiver()
        {
            InitializeComponent();
            viewModel = new NewPacketAddressReceiverViewModel(this);
            this.DataContext = viewModel.Data;
        }

        /// <summary>
        /// Gets the name of the view.
        /// </summary>
        /// <value>The name of the view.</value>
        public string ViewName
        {
            get { return "Adresse des Empfängers eingeben"; }
        }

        /// <summary>
        /// Sets the error info.
        /// </summary>
        /// <value>
        /// The error info.
        /// </value>
        public Dictionary<String, String> ErrorInfo
        {
            set { errorDict = value; }
        }

        private void OnLoaded(object sender, System.Windows.RoutedEventArgs e)
        {
            this.Vorname.EntryBox.Focus();
        }

        private void OnClick(object sender, RoutedEventArgs e)
        {
            if (viewModel.Data.HasError)
            {
                PTMessageBox.PTMessageBox message = new PTMessageBox.PTMessageBox(this);
                message.Show(errorDict);
            }
        }

        private Dictionary<String, String> errorDict;
        private NewPacketAddressReceiverViewModel viewModel;

    }
}
